package co.com.services.afiliacion;

import javax.naming.NamingException;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import co.com.smart.maestro.infraestructure.dto.AfiliacionDTO;
import co.com.smart.session.DelegateContextEJB;

@Path("/SmartAfiliacionServices")
public class AfiliacionServices {
	@GET
	@Path("/getAllAfiliacion")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getAfiliacion() throws NamingException {
		return Response.ok(DelegateContextEJB.getAfiliacionBeanLocal().consultarAllAfiliacion())
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@POST
	@Path("/getAfiliacionId")	
	@Produces(MediaType.APPLICATION_JSON)
	public Response getAfiliacionId(AfiliacionDTO json) throws NamingException {
		return Response.ok(DelegateContextEJB.getAfiliacionBeanLocal().consultarAfiliacionId(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/setAfiliacion")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setAfiliacion( AfiliacionDTO json){ 
		return Response.ok(DelegateContextEJB.getAfiliacionBeanLocal().insertarAfiliacion(json))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With")
				.build();
	}

	@PUT
	@Path("/editAfiliacion")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setEditAfiliacion(AfiliacionDTO json){ 
		return Response.ok(DelegateContextEJB.getAfiliacionBeanLocal().editAfiliacion(json))
		.header("Access-Control-Allow-Origin", "*")
		.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
		.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}

	@PUT
	@Path("/removeAfiliacion")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.APPLICATION_JSON)
	public Response setRemoveAfiliacion(AfiliacionDTO json){ 
		return Response.ok(DelegateContextEJB.getAfiliacionBeanLocal().removeAfiliacion(json, true))
				.header("Access-Control-Allow-Origin", "*")
				.header("Access-Control-Allow-Methods", "POST, GET, PUT, UPDATE, OPTIONS")
				.header("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With").build();
	}



}
